#!/bin/bash

# install virtualenvwrapper and bash to carry out code in self contained environment. Change path to appropriate path both here (lines 8, 25, 27, 29, 31, 33, 35) and in the "01_Create_TestSet.ipynb" (under set path). Then run this bash script from the command line using the command "bash 'path/to/replication/Replication Attempt 1/Step 1/Step 1.sh'"

source `which virtualenvwrapper.sh`

# Set appropriate path here
cd 'Path/to/replication/Replication Attempt 1'

# Create virtual environment
mkvirtualenv Replication2

# Open Virtual environment
workon Replication2

# Tests environment is working
echo "hello world"

# Install required packages in environment
pip install pdf2image
pip install PyPDF2
pip install ipykernel

# Make output directories for the selected training set to annotate. Change "Path/to/replication/" to appropriate path.
mkdir 'Path/to/replication/Replication Attempt 1/Step 2/Training Set'

mkdir 'Path/to/replication/Replication Attempt 1/Step 2/Training Set/Chula Vista'

mkdir 'Path/to/replication/Replication Attempt 1/Step 2/Training Set/Santa Rosa'

mkdir 'Path/to/replication/Replication Attempt 1/Step 2/Training Set/South San Francisco'

mkdir 'Path/to/replication/Replication Attempt 1/Step 2/Training Set/Temecula'

mkdir 'Path/to/replication/Replication Attempt 1/Step 2/Training Set/Visalia'

# Next three lines convert the ipynb file to a py file and runs the python script
chmod +x 'Step 1/Raw PDFS/01_Create_TestSet.ipynb'

jupyter nbconvert --to python 'Step 1/Raw PDFS/01_Create_TestSet.ipynb'

python 'Step 1/Raw PDFS/01_Create_TestSet.py'

